/**
 * 分类导航数据
 */

import { findHeadCategory } from '@/api/home'

export default {
  namespaced: true,

  state: {
    navs: []
  },

  mutations: {
    //   存储navs(同步)
    setNavs (state, navs) {
      state.navs = navs
    }
  },

  actions: {
    //   设置navs(异步)--调用后台获取navs的接口
    async getNavs ({ commit }) {
      const { result } = await findHeadCategory()// 结果中的result解构出来
      // console.log(result)
      commit('setNavs', result)
    }
  }
}
